<?php

function get_units(){
  $query = "SELECT * FROM unit";
  $qid = mysql_query($query);
  $units = array();
  while($row= mysql_fetch_object($qid)) {
      array_push($units, $row);
  }
  return $units;
}

function get_unit($id){
  $query = "SELECT * FROM unit WHERE unit_id = $id";
  $result = mysql_query($query);
  $unit = mysql_fetch_object($result);
  return $unit;
}

function print_unit($id, $q){
  $unit = get_unit($id);
  
  if($q > 1){
      return $unit -> unit_p;
  } else {
      return $unit -> unit_s;
  }
}
